import java.util.Scanner;

public class Test {

    public static void fun(int a) {
        if (a <10 ) {
            System.out.print(a+" ");
            return;
        }
        fun(a/10);
        System.out.print(a%10+" ");

    }

    public static int fun1(int a) {
        if (a == 1){
            return 1;
        }
         return a+fun1(a-1);

    }
    public static int fun2(int a) {
        if (a < 10) {
            return a;
        }

        return   a % 10+ fun2(a/10);


    }


    public static void main(String[] args) {

        //fun(123);
        //System.out.println(fun1(10));
        System.out.println(fun2(1729));
    }
    /*public static int fun(int a) {
        if (a == 1) {
            return 1;
        }
        return a*fun(a-1);


    }
    public static void main(String[] args) {
      int n=  fun(5);
        System.out.println(n);

    }*/
    public static void main5(String[] args) {
       /*
        斐波那契数
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int d1 = 1;
        int d2 = 1;
        int d3 = 0;
            if (i < 3) {
                System.out.println("1");
            } else {
                for (int j = 3; j <= i; j++) {
                    d3 = d1 + d2;
                    d1 = d2;
                    d2 = d3;
                }
            }
        System.out.println(d3);

*/
    }


   /* public static int max(int a,int b) {
        return a > b ? a : b;
    }

    public static int max(int a,int b,int c) {
        int maxNum = max(a,b);
        int ret = max(maxNum,c);
        return ret;
    }



    public static void main(String[] args) {



    }
*/






    public static void main4(String[] args) {
       /*
        模拟登陆密码
        int count = 3;
        Scanner sca = new Scanner(System.in);
        while(count != 0) {
            System.out.println("请输入密码：");
            String passWord = sca.nextLine();
            if(passWord.equals("12345678q")) {
                System.out.println("恭喜你登陆成功！");
                break;
            } else {
                count--;
                System.out.println("你还有"+count+"次机会。");
            }

        }
*/
    }
    public static void main3(String[] args) {
      /*
        输出输入数字的每一位
        Scanner sca = new Scanner(System.in);
        while(sca.hasNextInt()) {
            int i = sca.nextInt();
            while(i != 0) {
                System.out.print(i % 10);
                i /= 10;
            }


        }*/


    }
    public static void main2(String[] args) {
       /*
       计算1\1-1\2+1\3......1\100
       double sum = 0;
        int clunt = 1;
        for (int i = 1; i <= 100; i++) {
            sum += (clunt*(1.0 / i ));
            clunt = -clunt;
        }
        System.out.println(sum);*/
    }
    public static void main1(String[] args) {

        /*
        多组输入打印X图形
        Scanner sca = new Scanner(System.in);
        while(sca.hasNextInt()) {
            int i = sca.nextInt();
            for (int n = 0; n < i; n++) {
                for (int j = 0; j < i; j++) {
                    if(n == j || j + n == i-1) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.println();

            }


        }*/

    }

}
